const {Service}=require("egg")

class viewsService extends Service{

    async index(){
        const sql=`select * from auth_views`
        return await this.app.mysql.query(sql)
    }

    // 查看
    async show(id){
        const sql=`select * from auth_views where views_id=?`
        return await this.app.mysql.query(sql,[id])
    }

    // 编辑
    async update(id,views_text,views_url){
        const sql=`update auth_views set views_text=?,views_url=? where views_id=?`
        return await this.app.mysql.query(sql,[views_text,views_url,id])
    }

    // 删除
    async destroy(id){
        const sql=`DELETE FROM auth_views WHERE views_id=?`
        return await this.app.mysql.query(sql,[id])
    }

    // 增加
    async create(id,views_text,views_url){
        const sql=`insert into auth_views (views_id,views_text,views_url) values (?,?,?)`
        return await this.app.mysql.query(sql,[id,views_text,views_url])
    }
}

module.exports=viewsService